<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>广告管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$("#validDays").val('${advertisement.validDays}');
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		
		
		/////////////
		function addSeller(){
			
		}
		
		
		
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li><a href="${ctx}/ad/advertisement/">广告列表</a></li>
		<li class="active"><a href="${ctx}/ad/advertisement/form?id=${advertisement.id}">广告<shiro:hasPermission name="ad:advertisement:edit">${not empty advertisement.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="ad:advertisement:edit">查看</shiro:lacksPermission></a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="advertisement" action="${ctx}/ad/advertisement/save" method="post" class="form-horizontal"  enctype="multipart/form-data" >
		<form:hidden path="id"/>
		<form:hidden path="user.id"/>
		<form:hidden path="money" value="0"/>
		<tags:message content="${message}"/>
		
		
		<div class="control-group">
			<label class="control-label">广告(奖品)名称:</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="11" class="required"/>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">广告主:</label>
			<div class="controls">
                <tags:treeselect id="advertiser" name="advertiser.id" value="${advertisement.advertiser.id}" labelName="advertiser.name" labelValue="${advertisement.advertiser.name}"
					title="广告主" url="/sys/user/allUserTreeData"/>
			</div>
		</div>
		
		
		<div class="control-group">
			<label class="control-label">平台商家:</label>
			<div class="controls">
				<tags:treeselect id="sellerList" name="sellerIds" value="${advertisement.sellerIds}" checked="true"  labelName="sellerList.name"  labelValue="${advertisement.sellerNames}"
					title="平台商" url="/sys/user/allUserTreeData"/>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">投放类型:</label>
			<div class="controls">
				<form:select path="type">
					<form:option value="1">签到</form:option>					
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">增加积分:</label>
			<div class="controls">
				<form:input path="score" htmlEscape="false" maxlength="11" class="number"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">允许数量:</label>
			<div class="controls">
				<form:input path="repeatCount" htmlEscape="false" maxlength="11" class="number"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">允许数量周期:</label>
			<div class="controls">
				<form:select path="repeatCycleCount">
					<form:option value="">请选择</form:option>					
					<form:option value="1">周</form:option>					
					<form:option value="2">月</form:option>					
				</form:select>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">奖品有效天数:</label>
			<div class="controls">
				<select name="validDays" id="validDays">
					<% for(int i=1;i<31;i++) {%>
					<option value="<%=i%>" ><%=i %> 天</option>
					<%} %>
				</select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">奖品有效天数周期:</label>
			<div class="controls">
				<form:select path="validCycleEndday">
				<form:option value="">请选择</form:option>	
					<form:option value="1">周</form:option>					
					<form:option value="2">月</form:option>					
				</form:select>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">有效果时间:</label>
			<div class="controls">
				
					<script src="${ctxStatic}/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
					<input id="startTime" name="startTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
						value="<fmt:formatDate value="${advertisement.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
						onclick="WdatePicker({dateFmt:'yyyy-MM-dd 00:00:00',isShowClear:false});"/>  至
					<input id="endTime" name="endTime" type="text" readonly="readonly" maxlength="20" class="input-medium Wdate"
						value="<fmt:formatDate value="${advertisement.createTime}" pattern="yyyy-MM-dd HH:mm:ss"/>"
						onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',isShowClear:false});"/>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">回复图文标题:</label>
			<div class="controls">
				<form:input path="title" htmlEscape="false" maxlength="1000" class="required"/>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">连接URL:</label>
			<div class="controls">
				<form:input path="url" htmlEscape="false" maxlength="1000" class=""/>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">图片:</label>
			<div class="controls">
				<c:if test="${advertisement.picName ne '' }">
					<div class="control"><img src="${ctxUser }/advert/${advertisement.picName }" style="width:300px;height:100px"/></div>
				</c:if>
				<div class="control">
					<input type="file" name="picfile" htmlEscape="false"   />    <span class="alert">大图片建议尺寸：720像素 * 400像素;  小图片建议尺寸：400像素 * 400像素 </span>      
				</div>
			</div>
		</div>
		
		<div class="control-group">
			<label class="control-label">回复图文描述:</label>
			<div class="controls">
				<form:textarea path="description" htmlEscape="false" cols="50" rows="6" class="required"/>
			</div>
		</div>
		
		
			
		<div class="control-group">
			<label class="control-label">宣传内容:</label>
			<div class="controls">
				<form:textarea id="content" htmlEscape="true"  path="content" rows="4"  class="input-xlarge required"/>
				<tags:ckeditor replace="content" uploadPath="/advert/pics" />
			</div>
		</div>
		
			<div class="control-group">
			<label class="control-label">活动是否开启:</label>
			<div class="controls">
				<input type="radio" name="startup" value="1" <c:if test="${advertisement.startup eq true }">  checked="checked" </c:if> /> 是   <input type="radio" name="startup" value="0" <c:if test="${empty advertisement.startup or advertisement.startup eq false  }">  checked="checked" </c:if> /> 否
			</div>
		</div>
		
		<div class="form-actions">
			<shiro:hasPermission name="ad:advertisement:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>
